<?php
	session_start();

	if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
		header ("Location: index.php");
	}
	include("LangHeader.php");
	include ("config.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="scripts/salesmakeover.js"></script>
<title>Sales Makeover</title>
</head>

<body>
	<div class="container_head">
		<?php include("header.html"); ?>
	</div>
	<div class="container">
		<div class="editCompanyHeadline tr" key="show_User">Visar användare</div>
		<div class="content_edit" id="content_edit">
			
				<?php
					$companyID = $_SESSION['companyID'];
					$stmt = $con->prepare('SELECT Innovation.Name AS InnoName, Innovation.ID AS InnoID FROM Innovation INNER JOIN (SELECT User.ID, Company.ID as CompanyID, Company.Name AS CompanyName FROM User INNER JOIN Company ON User.CompanyID = Company.ID) AS T1 ON Innovation.OwnerID = T1.ID AND T1.CompanyID = ?');
					$stmt->bind_param('i', $companyID);
					$stmt->execute();
					$innovationresult = $stmt->get_result();

					echo "<div style='height:400px;margin-left: 15px;overflow-y:auto;'id='tableHolder' >";
					echo "<div style='width: 99%;border-bottom: 1px solid #333333;'>";
					while($row = $innovationresult->fetch_assoc())
					{
						
						echo "<div style='border-top:1px solid #333333; border-left: 1px solid #333333; border-right: 1px solid #333333;padding: 20px;'>";
						echo "<input type='checkbox' class='InnovationIDs' value=\"" . $row['InnoID'] . "\" >";
						echo $row['InnoName'];
						echo "</div>";
						
						
					}
					echo "</div>";
					echo "</div>";
				?>
				
			<span><div class="button tr" key="Export" style="float:right;margin-left:15px;margin-top:10px;" onclick="Export()">Export</div></span>
		
		</div>
	</div>




</body>

</html>
<script type="text/javascript">
function Export()
{
	var first = true;
	var empty=true;
	var IDS = "";
	$('.InnovationIDs').each(function() {
		
		if($(this).is(':checked'))
		{
			if(first)
				IDS += $(this).val();
			else
				IDS += "," + $(this).val();
				
			first = false;
			empty=false;
		}
		
	});
	if(!empty)
	document.location.href = 'csvoutput.php?IDS=' + IDS;
	else
	{
	alert(getText("list_NeedSelect"));

	}
};




$(document).ready(function () { 
	doResize();
	window.onresize = doResize;
});

</script>